# 猜大小游戏
import random

from Tools.scripts.objgraph import flat

print('########开始游戏#########')
if __name__ == "__main__":
    # 设置金豆数
    money = 1000
    # 赢的次数
    win = 0
    # 输的次数
    loss = 0
    while True:
        b = int(input("请输入你猜的结果,猜大输入1，猜小输入0："))
        m = int(random.randint(1, 6))
        n = int(random.randint(1, 6))
        q = int(random.randint(1, 6))
        M = m + n + q
        print("骰子点数和为", M)

        if M > 11:
            print("结果为大")
            flag = 1
            if b == 1:
                print("恭喜你，你猜对了")
                money = money + 100
                win = win + 1
            else:
                money = money - 100
                loss = loss + 1
                print("你输了，要继续加油喔")
        else:
            print('结果为小')
            flag = 0
            if b == 0:
                print("恭喜你，你猜对了")
                money = money + 100
                win = win + 1
            else:
                money = money - 100
                loss = loss + 1
                print("你输了，要继续加油喔")
        continue_string = input("是否继续? n/y")
        # 选择退出即退出
        if money < 100:
            print('您的本金已经为0，已被强制退出')
            print("您一共玩了", win+loss, "次")
            print("您一共赢了", win, "次")
            print("您一共输了", loss, "次")
            break

        if continue_string == "n":
            print("退出游戏成功")
            print("您一共玩了", win + loss, "次")
            print("您一共赢了", win, "次")
            print("您一共输了", loss, "次")
            break


# if b == 1:
#     print("恭喜你，你猜对了")
#     money = money + 100
#     win = win + 1
# elif b != 0:
#     money = money - 100
#     loss = loss + 1
#     if b == "大":
#         print("不好意思，你错了，你猜的是大，但 ", grade(M), "是小")
#     else:
#         print("不好意思，你错了，你猜的是小，但 ", grade(M), "是大")
#
# if money >= 100:
#     pass
# else:
#     print("你的金豆不足，已强制退出")
#     break
